const {app,BrowserWindow,Notification,ipcMain,globalShortcut}=require('electron');

let mainWindow = null;

app.on('ready',()=>{
    mainWindow=new BrowserWindow({
        width:1200,
        height:800,
        webPreferences: {
            nodeIntegration: true,
            contextIsolation: false,
            enableRemoteModule: true,
            devTools:true,
            nodeIntegrationInWorker: true
        },
        icon:'../favicon.ico'
    });
    mainWindow.webContents.openDevTools({mode:'right'});

    mainWindow.loadFile("./pages/main.html").then(r => {});


    const ret = globalShortcut.register('CommandOrControl+X', () => {
        console.log('CommandOrControl+X is pressed');
        setTimeout(()=>{
            sendMessage();
        },500)
    })



    mainWindow.on('close',()=>{
        mainWindow=null;
    })



})

const {getPlatform}=require('./platformTools')
function sendMessage(){
    const platform=getPlatform();
    mainWindow.webContents.send('change-mess',platform);
    console.log(platform);
}
